package com.lm.activiti.boot.tools.list;

import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Test;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author lm_jcf
 * @date 2020/5/13 17:36
 */
public class CollectionUtilsTest {

    @Test
    public void intersection(){

        List<Integer> list_1 = Lists.newArrayList( 3, 4);
        List<Integer> list_2 = Lists.newArrayList(1, 2, 3, 3);

        for (int i = 0; i < 1000; i++) {
            list_1.add(i);
            list_2.add(i);
        }

        System.out.println(list_1);

        System.out.println("开始时间戳：" + System.currentTimeMillis());
        System.out.println(CollectionUtils.intersection(list_1, list_2).size());
        System.out.println("结束时间戳：" + System.currentTimeMillis());


        System.out.println("开始时间戳：" + System.currentTimeMillis());
        System.out.println(list_1.stream().filter(element -> list_2.contains(element)).collect(Collectors.toList()).size());
        System.out.println("结束时间戳：" + System.currentTimeMillis());
    }
}
